package com.zzptc.sky.translate;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.RelativeLayout;


public class WelcomeActivity extends AppCompatActivity {

    RelativeLayout relativeLayout;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_welcome);
        relativeLayout= (RelativeLayout) findViewById(R.id.activity_welcome);
        initView();
    }
    //TODO   实现从欢迎界面跳转到
    private void initView() {
        System.out.println("<----wwwwwwwww---->");
        //对象动画的渐变属性改变界面的透明度
        ObjectAnimator animator = ObjectAnimator.ofFloat
                (relativeLayout, "alpha", 1f, 0f);
        animator.setDuration(3000);//动画执行的时间为3秒
        animator.start();
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                System.out.println("<-------wwwwwwwwwwww------------------------->");
                if(!Util.get(getApplicationContext())) {
                    startActivity(new Intent(WelcomeActivity.this, GuideActivity.class));
                }else {
                    startActivity(new Intent(WelcomeActivity.this, MainActivity.class));
                }
                finish();
//                //设置动画的属性
                overridePendingTransition(R.anim.out_to_left,R.anim.in_to_right);

            }
        });
    }

    }
